package lang.generics;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class GenericListUsageDemo
{
  public static void main(String[] args)
  {
    nonGeneric();
    generic();
  }

  private static void generic()
  {
    List<String> l = new ArrayList<String>();
    l.add("a string");
    //l.add(1);
    
    for(Iterator<String> it=l.iterator() ; it.hasNext() ; )
    {
      String o = it.next();
      System.out.println("Value is " + o);
    }
    
    String[] sa = l.toArray(new String[l.size()]);
  }

  private static void nonGeneric()
  {
    List l = new ArrayList();
    l.add("a string");
    l.add(1);
    
    for(Iterator it=l.iterator() ; it.hasNext() ; )
    {
      Object o = it.next();
      System.out.println("Value is " + o);
    }
    
    Object[] ar = l.toArray();
  }

}
